package com.lxt.cloud.testredis.service;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class RedisService {

    @Resource
    StringRedisTemplate stringRedisTemplate;


    public void saveLoginInfo(){
        stringRedisTemplate.opsForValue().set("zhangsan","123456");
        System.out.println("========================");
    }

    public Boolean saveLoginInfos() {
        try {
            Map<String, String> map = new HashMap<>();
            map.put("zhangsan","123456");
            map.put("lisi","123456");
            stringRedisTemplate.opsForHash().putAll("LOGININFO",map);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

}
